#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <map> 

#define flr(x, l, r) for (int x = l; x <= r; ++x)
#define frl(x, r, l) for (int x = r; x >= l; --x)
#define fmp(x, t) for (int x = h[t]; ~x; x = ne[x])
#define LL long long
#define mt memset
#define my memcpy
#define szf sizeof
#define INF 0x3f3f3f3f
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define inll(x) scanf("%lld", &x)
#define outll(x) printf("%lld", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector
#define pb push_back
#define sz size
#define PII pair<int, int>
#define x first
#define y second
#define P_q priority_queue
#define ft front
#define pf push_front
#define popf pop_front
#define it insert
#define ct count

using namespace std;

const int N = 110, M = N * N;

int n, m;
int h[N], e[M], ne[M], idx;
int scc_cnt, id[N], Size[N];
int dfn[N], low[N], timestamp;
int stk[N], top;
bool in_stk[N];
int din[N], dout[N];

void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void tarjan(int u) {
    dfn[u] = low[u] =  ++ timestamp;
    stk[ ++ top] = u, in_stk[u] = true;
    
    fmp (i, u) {
        int j = e[i];
        
        if (!dfn[j]) {
            tarjan(j);
            low[u] = min(low[u], low[j]);
        }
        else if (in_stk[j]) low[u] = min(low[u], dfn[j]);
    }
    
    if (dfn[u] == low[u]) {
        ++ scc_cnt;
        int y;
        do {
            y = stk[top -- ];
            in_stk[y] = false;
            id[y] = scc_cnt;
        } while (y != u);
    }
}

int main() {
	in(n);
	
	mt(h, -1, szf h);
	flr (i, 1, n) {
	    int t;
	    while (in(t), t) add(i, t);
	}
	
	flr (i, 1, n)
	    if (!dfn[i])
	        tarjan(i);
	        
	flr (i, 1, n)
	    fmp (j, i) {
	        int k = e[j];
	        int a = id[i], b = id[k];
	        if (a != b) 
	            din[b] ++ , dout[a] ++ ;
	    }
	
	int p = 0, q = 0;
	flr (i, 1, scc_cnt) {
	    if (!din[i]) p ++ ;
	    if (!dout[i]) q ++ ;
	}
	
	out(p), pn;
	if (scc_cnt == 1) puts("0");
	else out(max(p, q)), pn;
	
    return 0;
}